function Request(_name){
	var str=location.href;
	var arr=str.split("?");
	if(arr.length==2){
		var col=arr[1].split("&");
		for(var i=0; i<col.length; i++){
			var a=col[i].split("=");
			if(a[0]==_name){
				return a[1];
			}
		}
	}
	return "";
}

var arr;
//--------删除商品-----------
function delGoods(id){
	var txt=getCookie("g"+id);
	if(txt!=""){
		var obj=eval("("+txt+")");
		setCookie("g"+id, "", -10);
	}
}
var sum = 0;
var sum1 = 0;
var sum2 = 0;
var sum3 = 0;
onload =function(){
//--------top层账户与导航的下拉--------
	var myCount = document.getElementById("myCount");
	var degimg_0 = document.getElementById("degimg_0");
	var myCountul_0 = document.getElementById("myCountul_0");
	var netNav = document.getElementById("netNav");
	var degimg_1 = document.getElementById("degimg_1");
	var netNavul_0 = document.getElementById("netNavul_0");
	myCount.onmouseover = function(){
		degimg_0.style.transform = "rotate(180deg)";
		myCountul_0.style.display = "block";
		myCountul_0.style.border = "1px solid #ccc";
		myCountul_0.style.borderTop = "none";
	}
	myCount.onmouseout = function(){
		degimg_0.style.transform = "";
		myCountul_0.style.display = "none";
	}
	netNav.onmouseover = function(){
		degimg_1.style.transform = "rotate(180deg)";
		netNavul_0.style.display = "block";
		netNavul_0.style.border = "1px solid #ccc";
		netNavul_0.style.borderTop = "none";
	}
	netNav.onmouseout = function(){
		degimg_1.style.transform = "";
		netNavul_0.style.display = "none";
	}
//--------提示条的关闭--------
	var tipsclose = document.getElementsByClassName("tipsclose")[0];
	var tipsicon = document.getElementsByClassName("tipsicon")[0];
	var tipspop = document.getElementsByClassName("tipspop")[0];
	tipsclose.onclick = function(){
		tipsicon.style.display = "none";
		tipspop.style.display = "none";
	}
//--------注册成功后欢迎词的修改--------
	var welto = document.getElementsByClassName("welto")[0];
	var safel = document.getElementsByClassName("safel")[0];
	var tojoin = document.getElementsByClassName("tojoin")[0];
	var fre = document.getElementsByClassName("fre")[0];
	var userlogin=getCookie("userlogin");
	if(userlogin!=""){
		welto.innerHTML = "亲爱的";
		safel.innerHTML = userlogin;
		tojoin.innerHTML = "您好";
		fre.innerHTML = "[退出]";
	}
//------------把cookie中的商品添加到购物车里------------------
		showCart();
	//----showCart----
function showCart(){
	var str = document.cookie;
	var arrc = str.split("; ");
	for(var i=0;i<arrc.length;i++){
		var col = arrc[i].split("=");
		if( /^g[0-9]+$/.test(col[0]) ){
		var o=eval("("+decodeURIComponent(col[1])+")");
		var tb = document.createElement("table");
		var goods = document.getElementById("goods");
		goods.appendChild(tb);
		tb.style.width = "1200"+"px";
		tb.style.height = "70"+"px";
		tb.style.fontSize = "12px";
		tb.style.borderTop = "2px solid #c7012c";
		tb.style.borderBottom = "1px solid #999";
		tb.style.borderLeft = "1px solid #999";
		tb.style.borderRight = "1px solid #999";
		tb.style.marginLeft = "32"+"px";
		var _tr1 = document.createElement("tr");
		var _tr2 = document.createElement("tr");
		var _td1 = document.createElement("td");
		_td1.style.borderRight = "1px solid #999";
		_td1.style.borderBottom = "1px solid #999";
		var _td2 = document.createElement("td");
		var _td3 = document.createElement("td");
		var _td4 = document.createElement("td");
		var _td5 = document.createElement("td");
		var _td6 = document.createElement("td");
		var _td7 = document.createElement("td");
		var _td8 = document.createElement("td");
		var _td9 = document.createElement("td");
		var _img9 = document.createElement("img");
		var _td10 = document.createElement("td");
		var _td11 = document.createElement("td");
		var _inp1 = document.createElement("input");
		var _inp2 = document.createElement("input");	
		var _inp3 = document.createElement("input");
		_inp1.type = "button";
		_inp3.type = "button";
		_td11.appendChild(_inp1);
		_td11.appendChild(_inp2);
		_td11.appendChild(_inp3);
		_inp1.style.width = "16px";
		_inp1.style.height = "20px";
		_inp1.style.marginRight = "5px";
		_inp1.value = "-";
		_inp2.style.width = "20px";
		_inp2.style.height = "16px";
		_inp2.value = o.num;
		_inp3.style.width = "16px";
		_inp3.style.height = "20px";
		_inp3.style.marginLeft = "5px";
		_inp3.value = "+";
		var _td12 = document.createElement("td");
		var _td13 = document.createElement("td");
		var _td14 = document.createElement("td");
		var _td14a = document.createElement("a");
		tb.cellSpacing = "0";
		tb.cellPadding = "0";
		tb.style.textAlign = "center";
		tb.style.marginBottom = "10" +"px";
		_td1.style.width = "60" + "px";
		_td1.style.height = "35"+"px";
		_td2.style.width = "240" + "px";
		_td2.style.height = "35"+"px";
		_td2.style.borderBottom = "1px solid #999";
		_td3.style.width = "350" + "px";
		_td3.style.height = "35"+"px";
		_td3.style.borderBottom = "1px solid #999";
		_td4.style.width = "160" + "px";
		_td4.style.height = "35"+"px";
		_td4.style.borderBottom = "1px solid #999";
		_td5.style.width = "130" + "px";
		_td5.style.height = "35"+"px";
		_td5.style.borderBottom = "1px solid #999";
		_td6.style.width = "124" + "px";
		_td6.style.height = "35"+"px";
		_td6.style.borderBottom = "1px solid #999";
		_td7.style.width = "120" + "px";
		_td7.style.height = "35"+"px";
		_td7.style.borderBottom = "1px solid #999";
		_td8.style.width = "60" + "px";
		_td8.style.height = "70"+"px";
		_td8.style.borderRight = "1px solid #999";
		_td9.style.width = "240" + "px";
		_td9.style.height = "70"+"px";
		_td10.style.width = "350" + "px";
		_td10.style.height = "70"+"px";
		_td11.style.width = "160" + "px";
		_td11.style.height = "70"+"px";
		_td12.style.width = "130" + "px";
		_td12.style.height = "70"+"px";
		_td13.style.width = "124" + "px";
		_td13.style.height = "70"+"px";
		_td14.style.width = "120" + "px";
		_td14.style.height = "70"+"px";
		tb.appendChild(_tr1);
		tb.appendChild(_tr2);
		_tr1.appendChild(_td1);
		_tr1.appendChild(_td2);
		_tr1.appendChild(_td3);
		_tr1.appendChild(_td4);
		_tr1.appendChild(_td5);
		_tr1.appendChild(_td6);
		_tr1.appendChild(_td7);
		_tr2.appendChild(_td8);
		_tr2.appendChild(_td9);
		_td9.appendChild(_img9);
		_tr2.appendChild(_td10);
		_tr2.appendChild(_td11);
		_tr2.appendChild(_td12);
		_tr2.appendChild(_td13);
		_tr2.appendChild(_td14);
		_td14.appendChild(_td14a);   
		_td1.innerHTML = "<input type='checkbox' checked/>";
		_td2.innerHTML = "飞虎自营商品";
		_td3.innerHTML = "商品名称";
		_td4.innerHTML = "商品数量";
		_td5.innerHTML = "商品单价";
		_td6.innerHTML = "飞虎总价";
		_td7.innerHTML = "操作";
		_td8.innerHTML = "<input type='checkbox' checked/>";
		_img9.src = o.minsrc1;
		_td10.innerHTML =o.p;
		_td12.innerHTML = "￥"+o.span;
		_td13.innerHTML = o.span;
		_td14.innerHTML = "<a href='javascript:delGoods("+o.id+");'>删除</a>";
		var totalprice = document.getElementsByClassName("totalprice")[0];
		totalprice.innerHTML = Number(totalprice.innerHTML)+o.span*o.num;
		_inp1.onclick = function(){
			this.parentNode.parentNode.childNodes[3].childNodes[1].value--;
			if(this.parentNode.parentNode.childNodes[3].childNodes[1].value==0){
				alert("商品数量最少为1");
				delGoods(o.id);
				goods.removeChild(this.parentNode.parentNode.parentNode);
				history.go(0);
			}
			sum1 = Number(this.parentNode.parentNode.childNodes[5].innerHTML);
			totalprice.innerHTML = Number(totalprice.innerHTML)-sum1;
		}
		_inp3.onclick = function(){
			this.parentNode.parentNode.childNodes[3].childNodes[1].value++;
			sum2 = Number(this.parentNode.parentNode.childNodes[5].innerHTML);
			totalprice.innerHTML = Number(totalprice.innerHTML)+sum2;
		}	
		_td14.onclick = function(){
			goods.removeChild(this.parentNode.parentNode);
			history.go(0);
			if (goods.childNodes!="") {
				setCookie("length",goods.childNodes.length,-10);
			}
		}
	}

	}
	var goods = document.getElementById("goods");
		if (goods.innerHTML!="") {
			setCookie("length",goods.childNodes.length,100);
		}
}
	//---------根据id显示商品------------
	function getGoods(id){
		for(var i=0; i<arr.length; i++){
			var o=arr[i];
			if(o.id==id){
				return o;
			}
		}
	}


}